//package com.bitcola.security.statistics.consumer;
//
//
//import com.alibaba.fastjson.JSON;
//import com.bitcola.entity.ColaUser;
//import com.bitcola.entity.ColaUserEntity;
//import com.bitcola.security.statistics.feign.IDataServiceFeign;
//import com.bitcola.security.statistics.feign.IPushFeign;
//import lombok.extern.log4j.Log4j2;
//import org.apache.kafka.clients.consumer.ConsumerRecord;
//import org.springframework.beans.factory.annotation.Autowired;
//
//import org.springframework.kafka.annotation.KafkaListener;
//import org.springframework.kafka.core.KafkaTemplate;
//import org.springframework.stereotype.Service;
//import tk.mybatis.mapper.entity.Example;
//
//import javax.annotation.Resource;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.concurrent.ExecutorService;
//import java.util.concurrent.Executors;
//
//@Service
//@Log4j2
//public class UserConsumer {
//
//
//
//
//    ExecutorService executorService = Executors.newFixedThreadPool(100);
//    @Resource
//    IPushFeign pushFeign;
//
//
//
//    @Resource
//    IDataServiceFeign dataServiceFeign;
//
//
//    //用户kyc成功
//
//    @KafkaListener(topics = "user_register_success", containerFactory = "kafkaListenerContainerFactory")
//    public void user_checked_success(List<ConsumerRecord<String, String>> records) {
//        for (int i = 0; i < records.size(); i++) {
//            ConsumerRecord<String, String> record = records.get(i);
//            log.info("user_register_success:topic={},key={}", record.topic(), record.key());
//            ColaUserEntity userEntity = JSON.parseObject(record.value(), ColaUserEntity.class);
//            executorService.submit(() -> {
//                Map<String, String> content = new HashMap<>(2);
//                content.put("content", "用户uid :" + userEntity.getSysUserID() + "   电话:" + userEntity.getTelPhone() + " 邮箱: " + userEntity.getEmail() + " 注册,当前总共注册人数:" + 1);
//
////                pushFeign.push(content);
//
//            });
//
//
//        }
//        ;
//
//
//    }
//
//
//    @KafkaListener(topics = "user_withdraw_success", containerFactory = "kafkaListenerContainerFactory")
//    public void user_withdraw_success(List<ConsumerRecord<String, String>> records) {
//        for (int i = 0; i < records.size(); i++) {
//            int finalI = i;
//            executorService.submit(()->{
//                ConsumerRecord<String, String> record = records.get(finalI);
//                log.info("user_withdraw_success:topic={},key={}", record.topic(), record.key());
//                Map<String, String> content = new HashMap<>(2);
//                var withdraw=dataServiceFeign.getById(record.key());
//                content.put("content", "用户uid :" + withdraw.getUserId() + "  提现成功,币种: "+withdraw.getCoinCode()+" 数量: "+withdraw.getRealNumber()+"  hash: "+ withdraw.getTxId()  );
//                pushFeign.push(content);
//
//            });
//
//
//        }
//    }
//
//    @KafkaListener(topics = "user_charge_success", containerFactory = "kafkaListenerContainerFactory")
//    public void user_charge_success(List<ConsumerRecord<String, String>> records) {
//        for (int i = 0; i < records.size(); i++) {
//            int finalI = i;
//            executorService.submit(()->{
//                ConsumerRecord<String, String> record = records.get(finalI);
//                log.info("user_withdraw_success:topic={},key={}", record.topic(), record.key());
//                Map<String, String> content = new HashMap<>(2);
//                var withdraw=dataServiceFeign.getById(record.key());
//                 var user = dataServiceFeign.info(withdraw.getUserId());
//                 try {
//                     pushFeign.notice(user.getTelPhone(), " 尊敬的火盾会员 " + "  您的币种: " + withdraw.getCoinCode() +  " 已经充值成功 ");
//                 }catch (Throwable r){
//                     r.printStackTrace();
//                 }
//
//            });
//
//
//        }
//    }
//
//
//
//    @KafkaListener(topics = "user_withdraw_fail", containerFactory = "kafkaListenerContainerFactory")
//    public void user_withdraw_fail(List<ConsumerRecord<String, String>> records) {
//        for (int i = 0; i < records.size(); i++) {
//            int finalI = i;
//            executorService.submit(()-> {
//
//                ConsumerRecord<String, String> record = records.get(finalI);
//                log.info("user_withdraw_fail:topic={},key={}", record.topic(), record.key());
//                Map<String, String> content = new HashMap<>(2);
//                var withdraw = dataServiceFeign.getById(record.key());
//                content.put("content", "用户uid :" + withdraw.getUserId() + "  提现失败,币种: " + withdraw.getCoinCode() + " 数量: " + withdraw.getRealNumber() + "  失败原因: " + withdraw.getReason());
//                pushFeign.push(content);
//            });
//        }
//    }
//}